/*
 * adlibr - Library for mobile AD mediation.
 * http://adlibr.com
 * Copyright (c) 2012 Mocoplex, Inc.  All rights reserved.
 * Licensed under the BSD open source license.
 */

/*
 * confirmed compatible with ad@m SDK 2.0.3
 */

package com.crom.android.lottebaseball.ad;

import net.daum.adam.publisher.AdView.OnAdFailedListener;
import net.daum.adam.publisher.AdView.OnAdLoadedListener;
import net.daum.adam.publisher.impl.AdError;

import com.mocoplex.adlib.SubAdlibAdViewCore;

import android.content.Context;
import android.util.AttributeSet;

public class SubAdlibAdViewAdam extends SubAdlibAdViewCore  {
	
	protected net.daum.adam.publisher.AdView ad;

	public SubAdlibAdViewAdam(Context context) {
		this(context,null);
	}	
	
	public SubAdlibAdViewAdam(Context context, AttributeSet attrs) {
		super(context, attrs);
				
		ad = new net.daum.adam.publisher.AdView(context);
		
		ad.setOnAdLoadedListener(new OnAdLoadedListener() {
			@Override
			public void OnAdLoaded() {
				gotAd();
			} });
		
		ad.setOnAdFailedListener(new OnAdFailedListener() {
			@Override
			public void OnAdFailed(AdError arg0, String arg1) {
				failed();
			} });
	}
	
	// �ㅼ�以�����������쇰� �몄��⑸���
	// �ㅼ�濡�愿��瑜�蹂댁�二쇨린 �������껌�⑸���	
	public void query()
	{
		// �ш린��ADAM ID 瑜���������
		String adamID = "2c65Z0ET1377a2ece5a";
		
		// ��� 諛�� clientId �ㅼ�
		
		ad.setClientId(adamID);
		// 愿�� 媛깆� ��� : 湲곕낯 60珥�
		
		ad.setRequestInterval(12);

		this.addView(ad);
		
		this.gotAd();
	}
	
	// 愿��酉곕� ������ 寃쎌� �몄��⑸��� 
	public void clearAdView()
	{
		if(ad != null)
		{
			ad.destroy();
			ad = null;			
		}

		super.clearAdView();
	}
	
	public void onResume()
	{
		super.onResume();
		
		if(ad != null)
		{
			ad.resume();
		}
	}
	public void onPause()
	{
		super.onPause();
		
		if(ad != null)
		{
			ad.pause();
		}		
	}
}
